Release 10.1A: OpenEdge Development:
Programming Interfaces
Passing CHARACTER values to shared library routines
If you are passing a Progress character string to a shared library routine, you can pass it as a
CHARACTERvariable or expression. However, if you expect the shared library routine to modify the value, Progress Software recommends that you pass the Progress character string in aMEMPTRmemory region as a null-terminated string. This is required if it is anOUTPUTparameter. Otherwise, the shared library routine might inappropriately modify Progress memory outside the bounds of theCHARACTERvalue with unpredictable results. Assuming Progress has allocated the memory for the string (usingSET-SIZE), you then use theGET-STRINGfunction to extract theCHARACTERvalue.If the DLL alllocates the memory as either a
RETURNvalue or anOUTPUTparameter, you must use anOUTPUTMEMPTR. For aRETURNparameter, you can useGET-STRING(or another access function) directly on theMEMPTRon return. However, for anOUTPUTparameter, you must use theGET-POINTER-VALUEandSET-POINTER-VALUEfunctions to access the data on return. (For more information on theGET-andSET-POINTER-VALUEfunctions, see OpenEdge Development: Progress 4GL Reference .)The following code fragment shows how to pass an
INPUT-OUTPUTstring value as aMEMPTRparameter in the case where Progress allocates the memory:
The DLL routine is the tenth function in the
anysystem.dllfile. TheSET-SIZEstatement allocates to MemptrVar a memory region large enough to hold both the input and output CharString values. ThePUT-STRINGstatement stores the CharString value in MemptrVar. After passing MemptrVar to the DLL routine, theGET-STRINGstatement returns the (new) value to CharString.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |